/*******************************************************************************
 * Package: com.song.boot.springstudy.webflux
 * Type:    TransformationMain
 * Date:    2025/4/2 14:51
 *
 * Copyright (c) 2025 LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.song.boot.springstudy.webflux;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.time.Duration;

/**
 * 功能描述：转换操作
 *对数据流中的元素进行转换或映射。
 * @author Songxianyang
 * @date 2025/4/2 14:51
 */
public class TransformationMain {
    public static void main(String[] args) {
        Flux.range(1, 10).subscribe(System.out::println);
        System.out.println("----------");
        Flux.range(1, 10).map(v->v*2).subscribe(System.out::println);
        System.out.println("----------------------------");

        Flux.range(1, 10)  .flatMap(i -> Mono.just(i).delayElement(Duration.ofMillis(10))).subscribe(System.out::println);

    }
}
